package 线程的创建;
//实现Callable接口创建多线程
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
public class text3 {
    public static void main(String[] args) {
        new MyThread().start();
        //创建FutureTask对象
        FutureTask<String> futureTask = new FutureTask<>(new MyCallable());
        new Thread(futureTask).start();
        try {
            //获取线程的返回值
            String result = futureTask.get();
            System.out.println(result);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
class MyCallable implements Callable<String> {
    public String call() throws Exception {
        while(true){
            System.out.println("线程正在运行");
        }
        
    }
}